<template>
	<a-trigger position="br" trigger="click" auto-fit-position :unmount-on-close="true">
		<a-button type="outline">复制进度({{ copySuccess }}/{{ copyTotal }})</a-button>
		<template #content>
			<copy-list />
		</template>
	</a-trigger>
</template>
<script lang="ts" setup>
import { ref, onUnmounted, onMounted } from 'vue';
import { activity, errors } from '@/api';
import copyList from './copyList.vue';
const copyTotal = ref(0);
const copySuccess = ref(0);
let timeout: any;
const getCopyCount = async () => {
	try {
		const { data, ok } = await activity.getCopyCount();
		if (!ok) {
			return;
		}
		const { allCopyCount, successCopyCount } = data.data;
		copyTotal.value = allCopyCount;
		copySuccess.value = successCopyCount;
		if (allCopyCount > successCopyCount) {
			setTimeout(() => {
				getCopyCount();
			}, 8000);
		}
	} catch (error) {
		errors(error);
	}
};
onMounted(() => {
	getCopyCount();
});
onUnmounted(() => {
	clearInterval(timeout);
});
defineExpose({
	getCopyCount,
});
</script>
<style lang="less"></style>
